home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-07-25 | 2.1 KB | 75 lines |
- /*
- * Wall.java - THe 'walled' border
- * Copyright (C) 2000 Romain Guy
- * guy.romain@bigfoot.com
- * www.jext.org
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 331, Boston, MA 02111-1307, USA.
- */
-
- import waba.fx.*;
-
- /**
- * This class stands for a border which represents a brick wall.
- * @author Romain Guy <guy.romain@bigfoot.com>
- * @version 1.0
- */
-
- public class Wall
- {
- // pattern infos
- public static final byte PATTERN_WIDTH = 10;
- public static final byte PATTERN_HEIGHT = 6;
- // the length in pixels of the wall (width and height)
- private int lengthX, lengthY;
- // the pattern picture
- private Image patternImage;
-
- public Wall(int lengthX, int lengthY)
- {
- this.lengthX = lengthX;
- this.lengthY = lengthY;
-
- patternImage = new Image("datas/wall.bmp");
- }
-
- public void paint(Graphics g)
- {
- g.setColor(0, 0, 0);
- g.drawLine(0, lengthY - 1, lengthX, lengthY - 1);
-
- int num = lengthX / PATTERN_WIDTH;
- for (int i = 0; i < num; i++)
- {
- g.drawImage(patternImage, i * PATTERN_WIDTH, 15);
- g.drawImage(patternImage, i * PATTERN_WIDTH, lengthY - PATTERN_HEIGHT - 1);
- }
-
- num = (lengthY - 15) / PATTERN_HEIGHT;
- for (int i = 1; i < num - 1; i++)
- {
- g.drawImage(patternImage, 0, 15 + i * PATTERN_HEIGHT);
- g.drawImage(patternImage, lengthX - PATTERN_WIDTH, 15 + i * PATTERN_HEIGHT);
- }
- }
-
- public void free()
- {
- patternImage.free();
- }
- }
-
- // End of Wall.java
-